/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef DEV_PCIE_TRANSPORT_H
#define DEV_PCIE_TRANSPORT_H

#include <mc/engine.h>

namespace dev {

template <typename T>
using property = mc::engine::property<T>;

class transport_interface : public mc::engine::interface<transport_interface> {
public:
    MC_INTERFACE("bmc.kepler.Systems.Mctp.PCIeTransport")

    transport_interface()                                      = default;
    transport_interface(const transport_interface&)            = delete;
    transport_interface& operator=(const transport_interface&) = delete;

    property<std::string> m_service_name;
    property<uint8_t>     m_target_eid;
    property<uint16_t>    m_target_phy_addr;
    property<uint8_t>     m_message_type;
};

class transport_object : public mc::engine::object<transport_object> {
public:
    MC_OBJECT(transport_object, "PCIeTransport",
              "/bmc/kepler/Systems/1/Mctp/Transport/${TransportId}", (transport_interface))
    transport_object() : mc::engine::object<transport_object>(nullptr) {
    }
    transport_object(mc::core::object* parent) : mc::engine::object<transport_object>(parent) {
        m_transport_interface.set_parent(this);
    }
    transport_object(const transport_object&)            = delete;
    transport_object& operator=(const transport_object&) = delete;

    bool init(mc::dict& object);

    transport_interface m_transport_interface;
};

} // namespace dev

#endif // DEV_PCIE_TRANSPORT_H
